home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / bash-1.12 / dist / support / mail-shell < prev    next >
Encoding:
Text File  |  1991-07-07  |  1.3 KB  |  59 lines

  1. #!/usr/gnu/bin/bash
  2. #
  3. #  Mail the uuencoded files to USER.
  4. #
  5.  
  6. UUENCODED_DIR=uuencoded
  7.  
  8. if [ ! -d $UUENCODED_DIR ]; then
  9.   if make mailable; then :; else
  10.     echo "Cannot make the shell mailable."
  11.     exit
  12.   fi
  13. fi
  14.  
  15. if [ "$1" = "" ]; then
  16.   echo "Usage:  mail-shell <user>"
  17.   exit
  18. fi
  19.  
  20. unset -v files_to_send files_sent
  21. declare -i files_to_send files_sent
  22. count () { echo $#; }
  23.  
  24. files_to_send=$(count $UUENCODED_DIR/*.uu.*)
  25. files_sent=1
  26.  
  27. if [ ! -f $UUENCODED_DIR/inform ]; then
  28.   if [ -f inform ]; then
  29.      cat inform > $UUENCODED_DIR/inform
  30.   else
  31.      echo "No other information forthcoming.  Complain to bfox!" > $UUENCODED_DIR/inform
  32.   fi
  33.   echo "Here is a directory listing of the files to be sent." >>$UUENCODED_DIR/inform
  34.   (cd $UUENCODED_DIR; ls -l *.uu.* >> inform)
  35. fi
  36.  
  37. for recipient in $*; do
  38.   echo -n "Mailing $recipient information file..."
  39.   cat $UUENCODED_DIR/inform |
  40.     Mail -s "Here comes bash.  Expect $files_to_send files." $recipient
  41.   echo "done."
  42. done
  43.  
  44. for i in $UUENCODED_DIR/*.uu.*; do
  45.   mailfile=$(basename $i)
  46.   for recipient in $*; do
  47.      echo -n "Mailing $mailfile to $recipient..."
  48.      cat $i |
  49.         Mail -s \
  50.     "($files_sent of $files_to_send) Please save this in $mailfile" \
  51.     $recipient
  52.      echo "done."
  53.   done
  54.   let files_sent=$files_sent+1
  55. done
  56.  
  57. echo "Done mailing the shell to $*."
  58.  
  59.